<?php

namespace app\api\controller;

use app\common\controller\ApiController;
use app\common\lib\Show;

class Article extends ApiController
{
    public function getList(): \think\response\Json
    {
        if(!$this->request->isGet()){
            return Show::error([],'请求方式错误');
        }
        $keyword=$this->request->get('keyword');
        $type=$this->request->get('type');
        $pageNum=$this->request->get('pageNum');
        $pageSize=$this->request->get('pageSize');
        try {
            $list=\app\api\service\Article::getList($keyword,$type,$pageNum,$pageSize);
        }catch (\Exception $e){
            return Show::error([],$e->getMessage());
        }
        return Show::success($list);
    }
    public function getDetail(){
        if(!$this->request->isGet()){
            return Show::error([],'请求方式错误');
        }
        $id=$this->request->get('id');
        try {
            $row=\app\api\service\Article::getDetail($id);
        }catch (\Exception $e){
            return Show::error([],$e->getMessage());
        }
        return Show::success($row);
    }
}